<!DOCTYPE html>
<html lang="ko">
<head>
	<meta charset="UTF-8">
	<title>Sorting Arrays</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<!-- Bootstrap -->
	<link href="../css/bootstrap.min.css" rel="stylesheet" media="screen">
</head>
<body>
	<div class="container">
		<div class="row">
        	<div class="span12">
        	<table class="table table-bordered table-hover table-condensed">
        		<thead>
        			<th>Rating</th>
        			<th>Title</th>
        		</thead>
        	
	<?php # Script 2.8 - sorting.php
	
	// Create one array:
	$movies = array(10 => 'Casablanca', 
		9 => 'To Kill a Mockingbird',
		2 => 'The English Patient',
		8 => 'Stranger Than Fiction',
		5 => 'Story of the Weeping Camel',
		7 => 'Donnie Darko'
		);

	// Display the movies in their original order:
	echo '<tbody><tr><td colspan="2"><b>In their original order:</b></td></tr>';
	foreach ($movies as $key => $value) {
		echo "<tr><td>$key</td>
		<td>$value</td></tr>\n";
	}

	// Display the movies sorted by rating:
	krsort($movies);
	echo '<tr><td colspan="2"><b>Sorted by rating:</b></td></tr>';
	foreach ($movies as $key => $value) {
		echo "<tr><td>$key</td>
		<td>$value</td></tr>\n";
	}

	?>
					</tbody>
				</table>
			</div>
		</div>
	</div>
	<script src="http://code.jquery.com/jquery.js"></script>
	<script src="../js/bootstrap.min.js"></script>
</body>
</html>